import { Component } from '@angular/core'
import { Hero } from './hero.model'

@Component({
  selector: 'app-template-driven',
  templateUrl: './template-driven.component.html',
  styleUrls: [ './template-driven.component.scss' ],
})
export class TemplateDrivenComponent {
  powers = [ 'Really Smart', 'Super Flexible', 'Super Hot', 'Weather Changer' ]

  model = new Hero(18, 'Dr IQ', this.powers[ 0 ], 'Chuck Overstreet')

  submitted = false

  onSubmit() {
    this.submitted = true
  }

  newHero() {
    // this.model = new Hero(42, '', '')
    setTimeout(() => {
      Object.assign(this.model, new Hero(42, '新建 1', ''))
    }, 0)
    this.submitted = false
  }
}
